<?php
namespace app\common\model;

use think\Model;
use think\Db;
class Evaluate extends Model
{
	public function getCreateTimeAttr($val){
		return date('Y-m-d H:i:s',$val);
	}
	public function getUpdateTimeAttr($val){
		return date('Y-m-d H:i:s',$val);
	}
	//防止用户重复刷评论
	public function deny_insert($uid,$fid,$create_time){
		$last_data=$this->field('create_time')->where(array('uid'=>$uid,'fid'=>$fid))->order('create_time desc')->find();
		$first_today=60*60*24;
		$tomorrow=strtotime($last_data['create_time'])+$first_today;
		if($create_time < $tomorrow){
			return true;
		}else{
			return false;
		}
	}
	//图片分离
	public function getImgUrlAttr($val){
		if($val != ''){
			$newval=explode(',',$val);
			foreach ($newval as $k => $v) {
				if($newval[$k] == ''){
					unset($newval[$k]);
				}
			}
			return $newval;
		}else{
			return $val;
		}
	}
}